package com.sa.user.controller;

/**
 * @author Architecture Station
 * @version 1.0
 * @website 
 */

import cn.dev33.satoken.annotation.SaIgnore;
import com.sa.user.api.dto.PermissionDTO;
import com.sa.user.service.PermissionService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/permission")
@RequiredArgsConstructor
public class PermissionController {

    @Autowired
    private final PermissionService permissionService;

    @SaIgnore
    @GetMapping("/{roleId}/permissions")
    public List<PermissionDTO> loadPermissionsByRoleId(@PathVariable Integer roleId) {
        return permissionService.loadPermissionsByRoleId(roleId);
    }
}
